<?php
  //Buffer larger content areas like the main page content
  ob_start();
  require_once("auth.php");

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<link href="calender/tcal.css" type="text/css" rel="stylesheet">
<script src="calender/tcal.js" type="text/javascript"></script>
<script type="text/javascript" src="js/validationorder.js"></script>
<script>
var count=0;

function load(thediv, thefile) /* 2 parameters passed into here: the id of the div container and the name of the page to go to */
{  
    if (window.XMLHttpRequest)
    {
        xmlhttp = new XMLHttpRequest();
    }
    else
    {
        xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');  
    }
    xmlhttp.addEventListener("error", transferFailed, false);  
    xmlhttp.onreadystatechange = function()
    {
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
        {
            document.getElementById( thediv ).innerHTML = xmlhttp.responseText;
        }
    }  
 
   xmlhttp.open('GET', thefile, true);
    xmlhttp.send();
	    
}

function transferFailed(evt) {  
  alert("An error occurred while transferring the file.");  
}

</script>
</head>

<body>
<?php 
include("config.php");
if(isset($_REQUEST['id']))
{
$id=$_REQUEST['id'];
$data=mysql_query("select * from orders where OrderId='$id'");
$no=mysql_num_rows($data);
if($no!=0)
{
	while($rec=mysql_fetch_assoc($data))
	{

?>

<form action="updateorders.php" method="post"  enctype="multipart/form-data" id="frmOrders">
<fieldset >
<legend style="color:#FD0002">Update Order  </legend>			<div id="status"></div>

<table width="80%" align="center"><input type="hidden" value="<?php echo $id; ?>" name="id" />
<tr>
<td>Order Date :</td><td><input type="text" name="txtOrderDate" id="txtOrderDate" value="<?php
$odate=$rec['OrderDate'];
$od=explode("-", $odate);
$odate=$od[2].'-'.$od[1].'-'.$od[0];
echo $odate; ?>" class="tcal"></td>
</tr>
<tr>
<td >PaymentId: </td>
<td ><select id="ddlPaymentId" name="ddlPaymentId">

<?php 
							$data1=mysql_query("select * from payment order by PaymentID");
							$no1=mysql_num_rows($data1);
							if($no1!=0)
							{
								while($rec1=mysql_fetch_assoc($data1))
								{

							?>
							<option <?php if($rec['PaymentID']==$rec1['PaymentID']) echo "selected='selected'"; ?>><?php echo $rec1['PaymentID']; ?> </option>
							<?php
							}
							}
							?>

</select></td>
</tr>
<tr>
<td >Customer Id: </td>
<td ><select id="ddlCustomerId" name="ddlCustomerId">

<?php 
							$data1=mysql_query("select * from customers");
							$no1=mysql_num_rows($data1);
							if($no1!=0)
							{
								while($rec1=mysql_fetch_assoc($data1))
								{

							?>
							<option <?php if($rec['CustomerID']==$rec1['serial']) echo "selected='selected'"; ?> ><?php echo $rec1['serial']; ?> </option>
							<?php
							}
							}
							?>

</select></td>
</tr>
<tr>
<td>Shipper Id:</td><td><select  name="txtShipperId" id="txtShipperId">


						<?php 
							$data1=mysql_query("select * from shippers");
							$no1=mysql_num_rows($data1);
							if($no1!=0)
							{
								while($rec1=mysql_fetch_assoc($data1))
								{

							?>
							<option <?php if($rec['ShipperID']==$rec1['ShipperID']) echo "selected='selected'"; ?>><?php echo $rec1['ShipperID']; ?> </option>
							<?php
							}
							}
							?>
							</select>
</td>

</tr>

<tr>
<td>Sales Tax :</td><td><input type="text" name="txtSalesTax" id="txtSalesTax" value="<?php echo $rec['SalesTax']; ?>" onkeypress="return numbersonly(event);"></td>
</tr>
<tr><td>
<tr><td colspan="3"><input type="button" value="Update Orders" name="btnUpdateorders" onclick="validateForm2('updateorders.php','frmOrders','thediv','<img src=\'pleasewait.gif\'>');" /></td></tr>
</table>
</fieldset>
  	</form>


<?php
}}}
else
{
?>

<form action="addorders.php" method="post"  enctype="multipart/form-data" id="frmOrders">
<fieldset >
<legend style="color:#FD0002">Add Order  </legend>			<div id="status"></div>

<table width="80%" align="center">
<tr>
<td>Order Date :</td><td><input type="text" name="txtOrderDate" id="txtOrderDate" class="tcal"></td>
</tr>
<tr>
<td >PaymentId: </td>
<td ><select id="ddlPaymentId" name="ddlPaymentId">

<?php 
							$data1=mysql_query("select * from payment order by PaymentID");

							$no1=mysql_num_rows($data1);
							if($no1!=0)
							{
								while($rec1=mysql_fetch_assoc($data1))
								{

							?>
							<option <?php if($rec['PaymentID']==$rec1['PaymentID']) echo "selected='selected'"; ?>><?php echo $rec1['PaymentID']; ?> </option>
							<?php
							}
							}
							?>

</select></td>
</tr>
<tr>
<td >Customer Id: </td>
<td ><select id="ddlCustomerId" name="ddlCustomerId">

<?php 
							$data1=mysql_query("select * from customers");
							$no1=mysql_num_rows($data1);
							if($no1!=0)
							{
								while($rec1=mysql_fetch_assoc($data1))
								{

							?>
							<option ><?php echo $rec1['serial']; ?> </option>
							<?php
							}
							}
							?>

</select></td>
</tr>

<tr><td>Shipper Id:</td><td><select  name="txtShipperId" id="txtShipperId">


						<?php 
							$data1=mysql_query("select * from shippers");
							$no1=mysql_num_rows($data1);
							if($no1!=0)
							{
								while($rec1=mysql_fetch_assoc($data1))
								{

							?>
							<option ><?php echo $rec1['ShipperID']; ?> </option>
							<?php
							}
							}
							?>
							</select>
</td>
</tr>
<tr>
<td>Sales Tax :</td><td><input type="text" name="txtSalesTax" id="txtSalesTax" onkeypress="return numbersonly(event);"></td>
</tr>
<tr>
  <td colspan="3"><input type="button" value="Add Orders" name="btnAddorders"  onclick="validateForm2('addorders.php','frmOrders','thediv','<img src=\'pleasewait.gif\'>');"/></td>
</tr>
</table>
</fieldset>
  	</form>

<?php
}
?></body>
</html>
 <?php
  //Assign all Page Specific variables
  $pagemaincontent = ob_get_contents();
  ob_end_clean();
  $pagetitle = "Orders";
  //Apply the template
  include("master.php");
?>    